package com.bingxue.edu.management.education.model.entity;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.excel.annotation.ExcelProperty;
import com.bingxue.edu.common.enums.EnrollmentStatusEnum;
import com.bingxue.edu.framework.common.model.BusinessEntity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.handler.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * 报名信息
 *
 * @author zq
 * @since 2024/08/22
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Table("edu_enrollment")
public class Enrollment extends BusinessEntity {

    @Schema(description = "学员id")
    private String studentId;

    @Schema(description = "班级id")
    private String classId;

    @Schema(description = "报名课次数")
    //@ExcelProperty(index = 8,value = "报名课次数")
    private Integer enrollLessonCount;

    @Schema(description = "已上课次数")
    //@ExcelProperty(index = 9,value = "已上课次数")
    private Integer completedLessonCount;

    @Schema(description = "已退课次数")
    @ExcelProperty(index = 10, value = "已退课次数")
    private Integer cancelLessonCount;

    @Schema(description = "剩余可转班次数")
    private Integer remainClassChangeCount;

    @Schema(description = "剩余可调课次数")
    private Integer remainLessonChangeCount;

    @Schema(description = "续报班级id列表")
    @Column(typeHandler = JacksonTypeHandler.class)
    private List<String> renewalClassIds;

    @Schema(description = "报名信息状态")
    private EnrollmentStatusEnum status;

    @Schema(description = "销售顾问id")
    private String sellerId;

    @Schema(description = "备注（内部）")
    private String remark;

    @Schema(description = "是否续报")
    public Boolean getIsRenewal() {
        return CollUtil.isNotEmpty(this.renewalClassIds);
    }

    @Schema(description = "剩余课次")
    public Integer getRemainLessonCount() {
        return enrollLessonCount - completedLessonCount - cancelLessonCount;
    }
}
